﻿using BellAssistant.Model.Tables;
using BellAssistant.WebAPI.BLL;
using BellAssistant.WebAPI.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace BellAssistant.WebAPI.Controllers
{
    public class DataController : Controller
    {
        // GET: Sales
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult SaveGoods(Goods good)
        {
            
            bool saveFlg = DataBLL.SaveGoods(good);
            return CommonHelper.GetActionResult(saveFlg);
        }

        public ActionResult GetAllGoods()
        {
            List<Goods> list = DataBLL.GetAllGoods();
            return CommonHelper.GetActionResult(list);
        }

        public ActionResult SaveCategory(ProductCategory product, string newName = "")
        {

            bool saveFlg = DataBLL.SaveCategory(product, newName);
            return CommonHelper.GetActionResult(saveFlg);
        }

        public ActionResult GetAllProductCategory()
        {
            List<ProductCategory> list = DataBLL.GetAllProductCategory();
            return CommonHelper.GetActionResult(list);
        }

        public ActionResult SaveBrand(string brandName)
        {
            string result = DataBLL.SaveBrand(brandName);
            return CommonHelper.GetActionResult(result);
        }

        public ActionResult GetAllBrand()
        {
            List<Brand> list = DataBLL.GetAllBrand();
            return CommonHelper.GetActionResult(list);
        }

        public ActionResult SaveExpressType(ExpressType expressType)
        {
            string result = DataBLL.SaveExpressType(expressType);
            return CommonHelper.GetActionResult(result);
        }

        public ActionResult GetAllExpressType()
        {
            List<ExpressType> list = DataBLL.GetAllExpressType();
            return CommonHelper.GetActionResult(list);
        }

        public ActionResult GetAllPromotionType()
        {
            List<PromotionType> list = DataBLL.GetAllPromotionType();
            return CommonHelper.GetActionResult(list);
        }

        public ActionResult SavePromotionType(PromotionType promotionType)
        {
            string result = DataBLL.SavePromotionType(promotionType);
            return CommonHelper.GetActionResult(result);
        }

        public ActionResult GetProductCategoryIDByName(string categoryName)
        {
            int result = DataBLL.GetProductCategoryIDByName(categoryName);
            return CommonHelper.GetActionResult(result);
        }
        public ActionResult DelProductCategory(int id)
        {
            var result= DataBLL.DelProductCategory(id);
            return CommonHelper.GetActionResult(result);
        }
        public ActionResult GetBrandIDByName(string brandName)
        {
            int result = DataBLL.GetBrandIDByName(brandName);
            return CommonHelper.GetActionResult(result);
        }

        public ActionResult GetExpressTypeIDByName(string expressTypeName)
        {
            int result = DataBLL.GetExpressTypeIDByName(expressTypeName);
            return CommonHelper.GetActionResult(result);
        }


        public ActionResult GetPromotionIDByName(string promotionName)
        {
            int result = DataBLL.GetPromotionIDByName(promotionName);
            return CommonHelper.GetActionResult(result);
        }
    }
}